package com.cgc.dao.impl;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.MatchMode;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Component;

import com.cgc.dao.IMenuDao;
import com.cgc.entity.Dept;
import com.cgc.entity.Menu;

@Component
public class MenuDaoImpl extends BaseDaoImpl<Menu> implements IMenuDao<Menu> {

	@Override
	public DetachedCriteria getDetachedCriteria(Menu menu){
		DetachedCriteria dc = DetachedCriteria.forClass(Menu.class);
		if(menu!=null){
			if(null!=menu.getMenuname() && menu.getMenuname().trim().length()>0){
				dc.add(Restrictions.like("menuname", menu.getMenuname(),MatchMode.ANYWHERE));
			}
			if(null!=menu.getUrl()&& menu.getUrl().trim().length()>0){
				dc.add(Restrictions.like("url", menu.getUrl(),MatchMode.ANYWHERE));
			}
		}
	
		return dc;
		
	}
}
